using System;
using System.Collections.Generic;
using System.Text;
using Buka.BLL.Model;

namespace Buka.BLL.Provider
{
    [System.ComponentModel.DataObject()]
    public class EventProvider
    {
        Buka.DAL.EventsTableAdapters.EventsTableAdapter _eventTableAdapter = 
            new Buka.DAL.EventsTableAdapters.EventsTableAdapter();

        #region Methods

        public List<Event> GetAll()
        {
            List<Event> events = new List<Event>();
            foreach (Buka.DAL.Events.EventsRow row in _eventTableAdapter.GetData())
            {
                Event bukaEvent = new Event();
                bukaEvent = GetObjectFromDataRow(row);
                events.Add(bukaEvent);
            }
            return events;
        }

        #endregion


        #region "Fill & Get"

        public void FillObjectsFromDataRow(Buka.DAL.Events.EventsRow row, Event obj)
        {
            obj.Id = row.id;
            obj.Name = row.name;
        }

        public Event GetObjectFromDataRow(Buka.DAL.Events.EventsRow row)
        {
            Event bukaEvent=new Event();
            try 
	        {
                FillObjectsFromDataRow(row,bukaEvent);
	        }
	        catch (Exception ex)
	        {
		        throw new ArgumentException(ex.Message);
	        }
            return bukaEvent;
        }
        #endregion
    }
}
